<?php
/**
 * Created by PhpStorm.
 * User: kb130
 * Date: 2017/8/21
 * Time: 15:04
 */

namespace util\validate\rules;

/**
 * 验证值必须是整数
 *
 * Class Integer
 * @package validate\rules
 */
class Integer extends BaseRule
{
    public function verify()
    {
        if (0 === $this->value || 0 === strcmp($this->value, '0')) {
            return true;
        }

        $val = intval($this->value);

        if ($val == 0) {
            return false;
        }

        $this->value += 0;

        return is_int($this->value) && $this->value <= PHP_INT_MAX && $this->value >= PHP_INT_MIN;
    }
}